<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ page language="java" import="java.sql.* " %>
<%@page import="lookups.entity.TypeOfBusiness"%>
<%@page import="lookups.dao.TypeOfBusinessDAO"%>
<%@page import="java.util.ArrayList"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Type of Bussiness Lookup</title>
<link rel="stylesheet" type="text/css" href="css_tuan.css">
<!--  <link rel="stylesheet" type="text/css" href="stylelist.css">-->
<script type="text/javascript">

     function getselect(){
		    var radios = document.getElementsByName("tob");
			
		    for (var i = 0; i < radios.length; i++) {       
		        if (radios[i].checked) {
		            return radios[i].value;
		        }
		    }	   
	}
     function returnvalue(){
    	 selectval=getselect();
    	 
    	 bsname=document.getElementById(selectval).options[0].value;
    	 siccode=document.getElementById(selectval).options[1].value;
    	 
    	 window.opener.lookup.typeofbusiness.value=bsname;
    	 window.opener.lookup.siccode.value=siccode;
    	 self.close();
     }
     function returnnone(){
    	 window.opener.lookup.typeofbusiness.value=''; 
    	 window.opener.lookup.siccode.value='';
    	 self.close();
     }
     function loadonopen() {
    	onload=document.load.onload.value; 
    	alert(onload); 
    	if(onload==null){
    		//alert(document.load.onload.value);
			document.load.submit();
			document.load.onload.value=false;;
    	}
	 }
     window.onload=function hide(){
    	 var selecttag = document.getElementsByTagName('select');
    	 for(var i=0;i<selecttag.length;i++){
    		 selecttag[i].style.visibility = 'hidden';
    	 }
    	 
     }
     
</script>

</head>
<body  >
<div class="body">
	<div class="top"><b>Search Bussiness Type</b></div>
	<form action="typeofbusinesslookup" method="post" name="load" >
		<div class="div_color" align="justify">
			
			<div style="float:left"> Bussiness name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id="businessname" name="businessname"   value='<s:property value="businessname"/>' size="40"></div>
			<s:if test="onload==false">
				<div style="float:left"><input type="hidden" id="onload" name="onload" value='false' size="1" /></div>
			</s:if>
			<s:else>
				<div style="float:left"><input type="hidden" id="onload" name="onload" value="true" size="1" /></div>
			</s:else>
			
			<div style="float:right">SIC Code:<input type="text" id="siccode" name="siccode" value='<s:property value="siccode"/>' size="5"></div>
			
			<br>
		</div>
		<div class="margin">
			<input type="submit" name="searchtypeofbusiness" value="Search" >
			<input type="button" name="none" value="None" onclick="returnnone()">
			<input type="button" name="clear" value="Clear" onclick="document.getElementById('businessname').value='';document.getElementById('siccode').value='';">
		</div>
	
		<table border="1">
		
		<tr class="tr">
		<th class="th">&nbsp;&nbsp;&nbsp;</th>
		<th class="th">Bussiness name</th>
		<th class="th">SIC Code</th>
		<th class="th">&nbsp;&nbsp;&nbsp;&nbsp;</th>
		</tr>
		
		<s:iterator value="listtypeofbusiness" status="status">
		 <s:if test="#status.odd == true">
     		 <tr class="tr">
    	</s:if>
    	<s:else>
      		<tr class="tr_dark">
    	</s:else>
		<td>
			<input type="radio" id="tob" name="tob" value='<s:property value="typeID" />'>
			
		</td>
		<td><s:property value="businessName"/></td>
		<td><s:property value="SICCode"/></td>
		<td>
			<select id='<s:property value="typeID" />' >
				<option value='<s:property value="businessName"/>'></option>
  				<option value='<s:property value="SICCode"/>'></option>
			</select>
		</td>
		</tr>
		</s:iterator>
		
		</table> 
		
		<div class="paging" >
			<s:submit type="image" src="ic_prev.png"  width="16px" height="16px" action="previouspagetobaction"/>
				<input type="text" name="pageNum" value='<s:property value="pageNum"/>' size="1">/<b><s:property value="totalPage" /></b><input type="submit" name="Go" value="Go" size="1"  />
			<s:submit type="image" src="ic_next.png"  width="16px" height="16px" action="nextpagetobaction"/>
		</div>
		
		<br>
		<br>
		<input type="button" name="select" value="Select" onclick="returnvalue()"/>
		<input type="button" name="close" value="Close" onclick="window.close()">
		
		
	</form>
</div>
</body>
</html>